package es

import (
	"fmt"
	"github.com/elastic/go-elasticsearch/v7"
	"yk-travel-social/common/nacos"
)

var ES *elasticsearch.Client

func EsInit() {
	var err error
	nac := nacos.Config.Elasticsearch
	cfg := elasticsearch.Config{
		Addresses: []string{
			fmt.Sprintf("http://%s:%d", nac.Host, nac.Port),
		},
		// ...
	}
	ES, err = elasticsearch.NewClient(cfg)
	if err != nil {
		panic(err)
	}
	fmt.Println("elasticsearch init success")
}
